import myAxios_JWT from "@/request";
const JWT = "";

export const search = async (params) => {
  try {
    // 使用 fetch API 发起 POST 请求
    const response = await fetch("/v1/conversation/ask", {
      method: "POST",
      headers: {
        "Content-Type": "application/json",
        Authorization: `Bearer ${JWT}`,
      },
      body: JSON.stringify(params),
    });

    // 检查响应状态
    if (!response.ok) {
      throw new Error(`HTTP error! status: ${response.status}`);
    }

    // 解析响应数据
    return response.json();
  } catch (error) {
    console.error("Fetch error:", error);
    throw error;
  }
};
